package com.tianjipms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianjipms.dao.HouseMapper;
import com.tianjipms.entity.House;
import com.tianjipms.service.HouseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements HouseService {

    @Override
    public boolean existsByBuildingId(Long buildingId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("building_id", buildingId);
        return baseMapper.exists(queryWrapper);
    }

    @Override
    public boolean existsByHouseNumber(String houseNumber) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("house_number", houseNumber);
        return baseMapper.exists(queryWrapper);
    }
}
